package org.btik.light.nbi.cmd;

import org.btik.light.meta.base.Command;

import java.io.IOException;
import java.util.ArrayList;

/**
 * @author lustre
 * @since 2022/11/26 17:21
 */
public class RawCommand implements Command {

    private final byte[] rawCommand;

    private String target;

    @Override
    public String getTarget() {
        return target;
    }

    @Override
    public int opCode() {
        return 0;
    }

    @Override
    public ArrayList<?> getParams() {
        return null;
    }


    @Override
    public int getCmdId() {
        return -1;
    }

    @Override
    public byte[] encode() throws IOException {
        return rawCommand;
    }

    public RawCommand(byte[] rawCommand) {
        this.rawCommand = rawCommand;
    }

    @Override
    public String toString() {
        return new String(rawCommand);
    }

    public static RawCommand of(String sn, byte[] data) {
        RawCommand command = new RawCommand(data);
        command.target = sn;
        return command;
    }
}
